//  -------------------- iSharePoint -------------------- //
// 
//  Company:	IT Complex, LLC
//  Project:	Smart.Common
//  File name:	CacheEntryValue.cs
//  Developer:	Solomatov Igor
//  Created:	15.04.2012
// 
//  -------------------- iSharePoint -------------------- //

using System;

namespace Smart.Common
{
	[Serializable]
	public class CacheEntryValue<TValueType> : ICacheEntryValue
	{
		public DateTime Created = DateTime.Now;
		public DateTime Expires = DateTime.MaxValue;
		public TValueType Value;

		public CacheEntryValue()
		{
		}

		public CacheEntryValue(CacheEntryValue<TValueType> value)
		{
			Created = value.Created;
			Expires = value.Expires;
			Value = value.Value;
		}

		public CacheEntryValue(DateTime created, DateTime expires, TValueType value)
		{
			Created = created;
			Expires = expires;
			Value = value;
		}

		#region ICacheEntryValue Members

		public object Get()
		{
			return Value;
		}

		public bool IsExpired
		{
			get { return Expires < DateTime.Now; }
		}

		#endregion
	}
}